const app = getApp()
Page({
    data: {
        longitude: '',
        latitude: '',
    },
    onLoad() {
        this.Location()
    },
    regionchange(e) {
        // 地图发生变化的时候，获取中间点，也就是用户选择的位置toFixed
        if (e.type == 'end' && (e.causedBy == 'scale' || e.causedBy == 'drag')) {
            var that = this;
            this.mapCtx = wx.createMapContext("map4select");
            this.mapCtx.getCenterLocation({
                type: 'gcj02',
                success: function (res) {
                    console.log(res, 11111) //移动后，新位置的经纬度
                    that.setData({
                        latitude: res.latitude,
                        longitude: res.longitude
                    })
                }
            })
        }
    },
    //定位到自己的位置事件
    my_location: function (e) {
        var that = this;
        that.onLoad();
    },
    Location: function () {
        console.log("@@@location");
        var that = this;
        wx.getLocation({
            type: "gcj02",
            success: function (res) {
                console.log("111111111111");
                that.setData({
                    latitude: res.latitude,
                    longitude: res.longitude
                })
            },
            fail:function (res) {
                console.log(res);
            }
        })
    }
})